<?php echo $header;?>
<div id="content">
  <div class="box">
   <div class="heading">
      <h1><img src="view/image/information.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a></div>
    </div>
     <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
		<table class="form">
	      <tr>
		    <td><span class="required">*</span> <?php echo "社区名称"; ?></td>
            	<td ><label><?php echo $community['title'];?></label>
			</td>
			</tr>
			
	      <tr>
		    <td><span class="required">*</span> <?php echo "民警"; ?></td>
            	<td><input name="police_id" value="" type="text" />
			</td>
            </tr>
             <tr>
              <td>&nbsp;</td>
              <td><div id="police_route" class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php if($polices){?>
                   <?php foreach ($polices as $police) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div id="police_route<?php echo $police['police_id']; ?>" class="<?php echo $class; ?>"><?php echo $police['title']; ?><img src="view/image/delete.png" alt="" />
                    <input type="hidden" name="police_route[]" value="<?php echo $police['police_id']; ?>" />
                  </div>
                  <?php } ?>
                  <?php }?>
                </div></td>
            </tr>
        </table>
      </form>
      </div>
  </div>
  </div>
<script type="text/javascript"><!--
$('input[name=\'police_id\']').autocomplete({
	delay: 500,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=community/police/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						label: item.title,
						value: item.police_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('#police_route' + ui.item.value).remove();
		
		$('#police_route').append('<div id="police_route' + ui.item.value + '">' + ui.item.label + '<img src="view/image/delete.png" alt="" /><input type="hidden" name="police_route[]" value="' + ui.item.value + '" /></div>');

		$('#police_route div:odd').attr('class', 'odd');
		$('#police_route div:even').attr('class', 'even');
				
		return false;
	},
	focus: function(event, ui) {
      return false;
   }
});
$('#police_route div img').live('click', function() {
	$(this).parent().remove();
	
	$('#police_route div:odd').attr('class', 'odd');
	$('#police_route div:even').attr('class', 'even');	
});
//--></script> 

<?php echo $footer;?>
